package testMaker;

import java.util.Random;

import tools.DoubleVector;
import tools.Vector;

public class InstanceTools {
	
	public static Vector<Double> buildVector(int dim, double dev, double base){
		Vector<Double> vec = new DoubleVector(dim);
		Random gen = new Random();
		for(int i = 0; i < dim; i++){
			if(gen.nextBoolean()) vec.set(i, base + gen.nextDouble()*dev);
			else vec.set(i, base - gen.nextDouble()*dev);
		}
		return vec;
	}
	
	public static Vector<Double> buildVectorPos(int dim, double dev, double base){
		Vector<Double> vec = new DoubleVector(dim);
		Random gen = new Random();
		for(int i = 0; i < dim; i++){
			vec.set(i, base + gen.nextDouble()*dev);
		}
		return vec;
	}

	public static Vector<Double> buildVectorGeo(int dim, int type, double base) {
		Vector<Double> vec = new DoubleVector(dim);
		for(int i = 0; i < dim; i++){
			if(type == 0)vec.set(i, Math.cos(i*((2.0*Math.PI)/(double)dim))*base);
			else if(type == 1) vec.set(i, Math.sin(i*((2.0*Math.PI)/(double)dim))*base);
			else vec.set(i, Math.sin(i*((Math.PI)/2.0*(double)dim))*base);
		}
		return vec;
	}

	public static Vector<Double> buildVectorRandom(int dim, double base) {
		Vector<Double> vec = new DoubleVector(dim);
		Random gen = new Random();
		for(int i = 0; i < dim; i++){
			vec.set(i, base + gen.nextDouble()*base);
		}
		return vec;
	}

}
